Repository navigation
fix: search hidden files and keep partial repo_search results - #90
Conversation
Found 2026-11-09 driving the MCP repo tools against throwaway repos:
- ripgrep skips hidden files unless asked, so repo_search never found
anything in .github/, .eslintrc.cjs or .husky/, even with a glob such as
.github/**, while repo_read_file reads them. Search now passes --hidden.
Every result still goes through isAllowedRepoSearchResult, the same path
policy as reads, and the exclusion globs (now also the .git file of a
worktree) keep .env, .git, .bridge and key material unopened.
- ripgrep reports a line or path that is not UTF-8 as base64 "bytes", and
such matches were dropped. They are decoded lossily now.
- A path ripgrep could not read made it exit 2; the whole search failed
with the raw command line and the other matches were lost. Exit 2 with
matches now returns them (a regex error still gets its own message).
- Output over the 1 MB buffer failed as "too many matches" instead of
returning the first 100 marked truncated. The partial output is parsed
now; the error remains when it holds no complete match.
- A query with a line break failed with the raw command line; it now
says a search matches one line at a time.
- resolveRepoPath and the realpath check refused "..notes.md" as
escaping the root (relative.startsWith("..")).
Verified: tests/repo-search-gaps.test.ts fails 6 of 7 against main and
passes here; tests/repo.test.ts unchanged and passing; the original repro
scripts now return the expected results; npx tsc --noEmit; full suite
1872 passed, 3 skipped.
Not changed: a file name over about 192 bytes still fails apply with
ENAMETOOLONG on the temp file name (safe-file.ts).
Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
What this touches
3 file(s), 177 line(s) changed. Tests changed. This is an automated first pass, not a review. CI is the gate; a person decides. |
# Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adabbd0324
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!isRipgrepJsonMatch(event)) return undefined; | ||
| return { | ||
| path: normalizeRipgrepMatchPath(event.data.path.text), | ||
| path: normalizeRipgrepMatchPath(ripgrepText(event.data.path)), |
There was a problem hiding this comment.
Validate the original path bytes before lossy decoding
On Unix, lossily decoding a non-UTF-8 filename before passing it to isAllowedRepoSearchResult makes the security checks inspect a different file. I reproduced this with an invalid-byte filename bad-\xff.txt hard-linked to an outside secret and an ordinary, single-link file named bad-�.txt: searching for TOKEN returns the outside secret under the ordinary file's name because the realpath and hard-link checks validate that ordinary file instead. Previously these byte-path events were discarded. Preserve the original path bytes for filesystem validation, or reject paths that cannot round-trip through UTF-8, rather than using the replacement-character path for authorization.
Useful? React with 👍 / 👎.
# Conflicts: # CHANGELOG.md
…ch results) to the container image Same change as main PR #90 (merge d514236), released in 0.40.51, applied to src, tests and docs without changes. The CHANGELOG lines are main's with the PR noted. Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
Problems
Found 2026-11-09 by calling the MCP repo tool handlers against throwaway repos:
repo_searchnever searched hidden files..github/workflows/ci.yml,.eslintrc.cjsand.husky/returned no matches, even with the glob.github/**, althoughrepo_read_filereads them. ripgrep skips hidden files by default.bytes, and the parser requiredtext. The same applied to file names that are not UTF-8.truncated: true...notes.mdwas refused as escaping the repository, because the check wasrelative.startsWith("..").Changes (
src/repo.ts)--hidden. The exclusion globs gain!.gitand!**/.gitfor a worktree's.gitfile. Every result still passesisAllowedRepoSearchResult, the same path policy as reads.bytespaths and lines are decoded lossily.escapesRoot()treats only..or../...as leaving the root. It is used byresolveRepoPathand by the realpath check.Verification
tests/repo-search-gaps.test.ts: 7 cases. 6 fail against main; the seventh is a guard that sensitive dot-files stay out of the results. All 7 pass here.tests/repo.test.tspasses unchanged...notes.mdread.npx tsc --noEmitpasses. Full suite: 1872 passed, 3 skipped.repo_write_file_applywith ENAMETOOLONG on the temp file name (src/safe-file.ts).